<?php
namespace backend\controllers;

use backend\models\ClueOrgin;
use backend\models\Region;
use Yii;
use yii\data\Pagination;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use common\models\Admin;
use backend\models\Clue;
use backend\models\Enterprises;
use backend\models\ContactPeople;

/**
 * Clue controller
 */
class ContactPeopleController extends Controller
{
    public $enableCsrfValidation = false;//开启防止crf攻击
    //public $layout='base';
    /**
     * @inheritdoc
     */

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
        ];
    }


    /**
     * 企业的首页面
     */
    public function actionIndex()
    {
        $contactList=ContactPeople::find()->joinWith('enterprise')->joinWith('citys')->joinWith('provinces')->asArray()->all();
        var_dump($contactList);
        die;
        return $this->renderPartial('index');
    }

    /**
     * 添加联系人
     */
   public function actionEditContactPeopled(){
       $params=Yii::$app->request->post();
       if($id>0){
           $contactPeople=ContactPeople::findOne(['id'=>$id]);
           if(empty($contactPeople)){
               returnResult(100028,'无法找到该联系人');
           }
       }else{
           $contactPeople=new ContactPeople();
       }
       $contactPeople->contactName='小王';
       $contactPeople->agentAccount='123456654';
       $contactPeople->toCustomer='某某企业';
       $contactPeople->enterpriseId=1;;
       $contactPeople->job='职务';
       $contactPeople->phone='76691565';
       $contactPeople->wechatId='zjhyushen';
       $contactPeople->QQ='1105730947';
       $contactPeople->chargePerson='负责人';
       $contactPeople->adminId=3;
       $contactPeople->collaborator='某某合作者';
       $contactPeople->lastFollowTime=time();
       $contactPeople->nextFollowTime=time();
       $contactPeople->remarks='一些备注';
       $contactPeople->isAgent=1;
        $doResult=$contactPeople->save();
       if($doResult){
           returnResult(0,'操作联系人成功');
       }else{
           returnResult(100029,'操作联系人失败');
       }
   }





}
